library(plotly)
Registered S3 method overwritten by 'data.table':
  method           from
  print.data.table     
Registered S3 methods overwritten by 'htmltools':
  method               from         
  print.html           tools:rstudio
  print.shiny.tag      tools:rstudio
  print.shiny.tag.list tools:rstudio
Registered S3 method overwritten by 'htmlwidgets':
  method           from         
  print.htmlwidget tools:rstudio

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

    last_plot

The following object is masked from ‘package:stats’:

    filter

The following object is masked from ‘package:graphics’:

    layout
ourfinaldata %>% 
  filter(Confirmed > 200 & Country_Region != "China")%>%
  plot_ly(x = ~Date, y = ~Confirmed, color = ~Country_Region, mode = 'lines')
No trace type specified:
  Based on info supplied, a 'scatter' trace seems appropriate.
  Read more about this trace type -> https://plot.ly/r/reference/#scatter
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
No trace type specified:
  Based on info supplied, a 'scatter' trace seems appropriate.
  Read more about this trace type -> https://plot.ly/r/reference/#scatter
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors

  #ggplot(mapping = aes(x = Date, y = Confirmed, color=Country_Region))+
  #geom_line()
p<-ourfinaldata %>% 
  filter(Confirmed > 200 & Date == "2020-03-19" & Country_Region != "China" )

plot_ly(p,x = ~NY.GDP.PCAP.KD, y = ~ Confirmed, color = ~Country_Region, size = 2 )%>%
  layout(xaxis=list(range = c(min(0),max(90000))), yaxis = list(range = c(min(0), max(42000))))
No trace type specified:
  Based on info supplied, a 'scatter' trace seems appropriate.
  Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
  Setting the mode to markers
  Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
Ignoring 5 observationsn too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
No trace type specified:
  Based on info supplied, a 'scatter' trace seems appropriate.
  Read more about this trace type -> https://plot.ly/r/reference/#scatter
No scatter mode specifed:
  Setting the mode to markers
  Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
Ignoring 5 observationsn too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors

  
  #ggplot(mapping = aes(x = NY.GDP.PCAP.KD, y = Confirmed, fill=Country_Region))+
  #geom_col(width = 2000)

p <- ourfinaldata %>% 
  filter(Confirmed > 200 & Date == "2020-03-19" & Country_Region != "China")




p%>%
  plot_ly(x = ~country_ave_temp, y = ~ Confirmed, mode = "markers", color = ~Country_Region, size=2)%>%
  layout(xaxis=list(range = c(min(-40),max(40))), yaxis = list(range = c(min(0), max(42000))))%>%
  add_markers(y = ~Confirmed, text = rownames(~Country_Region))
Ignoring 5 observationsn too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
Ignoring 5 observationsn too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors

  #ggplot(mapping = aes(x = country_ave_temp, y = Confirmed, fill=Country_Region))+
  #geom_col(width = 1)
ourfinaldata %>% 
  filter(Confirmed > 100 & Date == "2020-03-19" & Country_Region != "China" )%>%
  plot_ly(x = ~Country_Region, y = ~Confirmed, color = ~Country_Region)
No trace type specified:
  Based on info supplied, a 'bar' trace seems appropriate.
  Read more about this trace type -> https://plot.ly/r/reference/#bar
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
No trace type specified:
  Based on info supplied, a 'bar' trace seems appropriate.
  Read more about this trace type -> https://plot.ly/r/reference/#bar
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
p%>%select(-Date, -Lat, -Long)%>% summary()
 Province_State     Country_Region       Confirmed           Deaths         Recovered       NY.GDP.PCAP.KD  
 Length:44          Length:44          Min.   :  217.0   Min.   :   0.0   Min.   :   0.00   Min.   :  1198  
 Class :character   Class :character   1st Qu.:  325.2   1st Qu.:   1.0   1st Qu.:   2.75   1st Qu.: 18307  
 Mode  :character   Mode  :character   Median :  679.0   Median :   6.0   Median :  10.50   Median : 43325  
                                       Mean   : 3558.3   Mean   : 148.5   Mean   : 319.36   Mean   : 39203  
                                       3rd Qu.: 1849.5   3rd Qu.:  26.0   3rd Qu.:  47.75   3rd Qu.: 54801  
                                       Max.   :41035.0   Max.   :3405.0   Max.   :5710.00   Max.   :110742  
                                                                                            NA's   :5       
 country_ave_temp  Population_2020    
 Min.   :-18.053   Min.   :   341243  
 1st Qu.:  7.806   1st Qu.:  5850342  
 Median :  9.660   Median : 19237691  
 Mean   : 12.659   Mean   : 54053047  
 3rd Qu.: 21.120   3rd Qu.: 67886011  
 Max.   : 26.785   Max.   :331002651  
 NA's   :5         NA's   :3          
library(moderndive)
p <- ourfinaldata %>% 
  filter(Confirmed > 200 & Date == "2020-03-19" & Country_Region != "China")
p %>% get_correlation( Confirmed ~ country_ave_temp, na.rm = T)
reg <- lm(Confirmed ~ country_ave_temp,data = p)
reg

Call:
lm(formula = Confirmed ~ country_ave_temp, data = p)

Coefficients:
     (Intercept)  country_ave_temp  
          3930.9             -51.4  
get_regression_table(reg)
p <- ourfinaldata %>% 
  filter(Confirmed > 100 & Date == "2020-03-19" & Country_Region != "China")
p %>% ggplot(mapping = aes(x = Population_2020, y = Confirmed))+
  geom_point()+
  geom_smooth(aes(y=Confirmed, x =  Population_2020))

p <- ourfinaldata %>% 
  filter(Confirmed > 200 & Date == "2020-03-19" & Country_Region != "China")

p%>%
  plot_ly(x = ~Population_2020, y = ~ Confirmed, mode = "markers", color = ~Country_Region, size=2)
No trace type specified:
  Based on info supplied, a 'scatter' trace seems appropriate.
  Read more about this trace type -> https://plot.ly/r/reference/#scatter
Ignoring 3 observationsn too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
No trace type specified:
  Based on info supplied, a 'scatter' trace seems appropriate.
  Read more about this trace type -> https://plot.ly/r/reference/#scatter
Ignoring 3 observationsn too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
n too large, allowed maximum for palette Set2 is 8
Returning the palette you asked for with that many colors
LS0tCnRpdGxlOiAiSlBGaWxlIgpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sKLS0tCgoKCmBgYHtyfQpsaWJyYXJ5KHRpZHl2ZXJzZSkKbGlicmFyeShwbG90bHkpCnNldHdkKCJ+L1N0YXRzX1Byb2plY3QiKQpvdXJmaW5hbGRhdGEgPSByZWFkX2Nzdigib3VyZmluYWxkYXRhLmNzdiIpCm91cmZpbmFsZGF0YSREYXRlIDwtYXMuRGF0ZShvdXJmaW5hbGRhdGEkRGF0ZSwgZm9ybWF0ID0gIiVtLyVkLyV5IikKb3VyZmluYWxkYXRhJT4lCiAgYXJyYW5nZShkZXNjKENvdW50cnlfUmVnaW9uKSkKYGBgCgpgYGB7cn0Kb3VyZmluYWxkYXRhICU+JSAKICBmaWx0ZXIoQ29uZmlybWVkID4gMjAwICYgQ291bnRyeV9SZWdpb24gIT0gIkNoaW5hIiklPiUKICBwbG90X2x5KHggPSB+RGF0ZSwgeSA9IH5Db25maXJtZWQsIGNvbG9yID0gfkNvdW50cnlfUmVnaW9uLCBtb2RlID0gJ2xpbmVzJykKCiAgI2dncGxvdChtYXBwaW5nID0gYWVzKHggPSBEYXRlLCB5ID0gQ29uZmlybWVkLCBjb2xvcj1Db3VudHJ5X1JlZ2lvbikpKwogICNnZW9tX2xpbmUoKQpgYGAKCmBgYHtyfQpwPC1vdXJmaW5hbGRhdGEgJT4lIAogIGZpbHRlcihDb25maXJtZWQgPiAyMDAgJiBEYXRlID09ICIyMDIwLT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